package bancosys.tec.services.input;

import java.util.List;

import jmine.tec.di.scope.TypedScope;
import jmine.tec.services.ServicesController;
import jmine.tec.services.api.ActionsEnum;
import jmine.tec.services.api.Service;
import jmine.tec.services.api.ServiceExecutionException;
import jmine.tec.services.api.ServicesPage;

import org.springframework.transaction.TransactionDefinition;

import bancosys.tec.persist.controller.PersistenceEnabledController;

/**
 * Classe que deve servir como 'proxy' para um Servico
 * 
 * @author takeshi
 * @param <C>
 */
public class ForwardingService<C extends PersistenceEnabledController> implements Service<C> {

    private final Service delegate;

    /**
     * @param delegate o Delegate
     */
    public ForwardingService(Service<?> delegate) {
        super();
        this.delegate = delegate;
    }

    /**
     * {@inheritDoc}
     */
    public void execute() throws ServiceExecutionException {
        this.getDelegate().execute();
    }

    /**
     * {@inheritDoc}
     */
    public ActionsEnum getAction() {
        return this.getDelegate().getAction();
    }

    /**
     * {@inheritDoc}
     */
    @SuppressWarnings({ "unchecked", "deprecation" })
    public C getController() {
        return (C) this.getDelegate().getController();
    }

    /**
     * {@inheritDoc}
     */
    @SuppressWarnings({ "unchecked", "deprecation" })
    public Class<C> getControllerClass() {
        return this.getDelegate().getControllerClass();
    }

    /**
     * {@inheritDoc}
     */
    public String getServiceLocation() {
        return this.getDelegate().getServiceLocation();
    }

    /**
     * {@inheritDoc}
     */
    public String getServiceName() {
        return this.getDelegate().getServiceName();
    }

    /**
     * {@inheritDoc}
     */
    public TypedScope getServiceProperties() {
        return this.getDelegate().getServiceProperties();
    }

    /**
     * {@inheritDoc}
     */
    public ServicesController getServicesController() {
        return this.getDelegate().getServicesController();
    }

    /**
     * {@inheritDoc}
     */
    public ServicesPage getServicesPage() {
        return this.getDelegate().getServicesPage();
    }

    /**
     * {@inheritDoc}
     */
    @SuppressWarnings({ "unchecked", "deprecation" })
    public void setController(C controller) {
        this.getDelegate().setController(controller);
    }

    /**
     * {@inheritDoc}
     */
    public void setServiceLocation(String serviceLocation) {
        this.getDelegate().setServiceLocation(serviceLocation);
    }

    /**
     * {@inheritDoc}
     */
    public void setServiceProperties(TypedScope serviceProperties) {
        this.getDelegate().setServiceProperties(serviceProperties);
    }

    /**
     * {@inheritDoc}
     */
    public void setServicesController(ServicesController servicesController) {
        this.getDelegate().setServicesController(servicesController);
    }

    /**
     * {@inheritDoc}
     */
    public void setServicesPage(ServicesPage servicesPage) {
        this.getDelegate().setServicesPage(servicesPage);
    }

    /**
     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
    public List<String> validate() {
        return this.getDelegate().validate();
    }

    /**
     * {@inheritDoc}
     */
    public TransactionDefinition getTransactionDefinition() {
        return this.getDelegate().getTransactionDefinition();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    @SuppressWarnings("deprecation")
    public Service<C> clone() throws CloneNotSupportedException {
        return new ForwardingService<C>(this.getDelegate().clone());
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        return this.getDelegate().toString();
    }

    /**
     * @return Service
     */
    public Service getDelegate() {
        return this.delegate;
    }
}
